package facilius.controller.action.usuario;

import facilius.model.ServiceLocator;
import java.util.HashMap;
import java.util.Map;
import org.mentawai.core.BaseAction;

/**
 *
 * @author Graciano
 */
public class UsuarioReadAction extends BaseAction {

    @Override
    public String execute() throws Exception {
        String consequence = ERROR;
        try {
            Map<String, Object> criteria = new HashMap<String, Object>();
            String nome = input.getString("nome");
            if (nome != null && !nome.isEmpty()) {
                criteria.put("nome", nome);
            }
            output.setValue("pojos", ServiceLocator.getUsuarioService().readByCriteria(criteria));
            consequence = SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return consequence;
    }
}
